package com.appcheck.recording.handler.impl;

import android.view.ViewGroup;
import android.widget.AdapterView;

import com.appcheck.recording.ListenerManager;
import com.appcheck.recording.PreViewManager;
import com.appcheck.recording.action.impl.ScrollListAction;
import com.appcheck.recording.action.impl.ScrollStateChangedAction;
import com.appcheck.recording.utils.Logger;

public class ScrollGrouper extends Grouper {

	private ScrollListAction action;
	
	public ScrollGrouper(Grouper paramGrouper) {
		super(paramGrouper);
	}

	public final boolean visit(ScrollListAction action){
		this.action = action;//记录最后一个ScrollListAction
		return true;
	}
	
	public final boolean visit(ScrollStateChangedAction action){
		if((action.getScrollState() == 0) && (this.action != null)){
			forwardActionToPlugin(this.action);
			//滑动动作结束，需要重新加载AdapterView中的子控件
			Logger.INFO("call setListenersManuallyFromRoot");
			
			PreViewManager preViewIdManager = new PreViewManager((AdapterView)this.action.getAbsListView());
			ListenerManager.getListenerManager().setListenersManuallyFromRoot((ViewGroup)this.action.getAbsListView(), true, preViewIdManager);
		}
		return true;
	}

}
